package edu.washington.cs.sounddetector.server.api.methodresult;

import edu.washington.cs.sounddetector.server.api.MethodResult;
import edu.washington.cs.sounddetector.server.api.method.RenameDetector;

public class RenameDetectorResult extends MethodResult<RenameDetector>
{
    private String detectorId;

    private RenameDetectorResult(boolean successful, FailureReason reason, String detectorId)
    {
        super(successful, reason);
        this.detectorId = detectorId;
    }

    private RenameDetectorResult()
    {
        this(true, null, null);
    }

    /**
     * @return if {@link #isSuccessful()} returns false, returns the detectorId that does not exist.
     *         Otherwise returns null.
     */
    public String getDetectorId()
    {
        return this.detectorId;
    }

    public static RenameDetectorResult success()
    {
        return new RenameDetectorResult(true, null, null);
    }

    public static RenameDetectorResult failureDetectorIdDoesNotExist(String detectorId)
    {
        return new RenameDetectorResult(false, FailureReason.DETECTOR_ID_DOES_NOT_EXIST, detectorId);
    }

}
